package main

import (
	"fmt"
	"math"
	"math/rand"
)

func main() {
	/**
	var pi64 = math.Pi
	var pi32 float32 = math.Pi

	// float32相较64精度更差
	// math包中操作的都是float64

	fmt.Println(pi64)
	fmt.Println(pi32)

	third := 1.0 / 3
	fmt.Println(third)
	fmt.Printf("%v\n", third)
	fmt.Printf("%f\n", third)
	fmt.Printf("%.3f\n", third)
	fmt.Printf("%06.2f\n", third)

	// 浮点类型计算精度有问题，为了减少错误应该先乘法再除法
	*
	*/
	var coins = []float64{0.05, 0.10, 0.25}
	var collect float64 = 0.0

	for math.Abs(collect-20) > 0.0001 && collect < 20 {
		var coin = coins[rand.Intn(3)]
		collect += coin
		fmt.Printf("%05.2f\n", collect)
	}
}
